//
//  ViewController.m
//  Demo0035
//
//  Created by zTercel on 13-4-7.
//  Copyright (c) 2013年 zTercel. All rights reserved.
//
#import "CustomTableViewCell.h"
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

static NSString *cellIdentifier  = @"CellTableViewIdentify";

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    NSDictionary    *phone1  = [[NSDictionary alloc]initWithObjectsAndKeys:@"易容活",   @"Name", @"186-8878-6226", @"Phone", nil];
    NSDictionary    *phone2  = [[NSDictionary alloc]initWithObjectsAndKeys:@"马琳琳",   @"Name", @"132-3428-6321", @"Phone", nil];
    NSDictionary    *phone3  = [[NSDictionary alloc]initWithObjectsAndKeys:@"韩单红",   @"Name", @"186-3452-3462", @"Phone", nil];
    NSDictionary    *phone4  = [[NSDictionary alloc]initWithObjectsAndKeys:@"周右保",   @"Name", @"159-8297-6247", @"Phone", nil];
    NSDictionary    *phone5  = [[NSDictionary alloc]initWithObjectsAndKeys:@"郭风民",   @"Name", @"154-1247-1226", @"Phone", nil];
    
    self.phoneBook = [[NSArray alloc]initWithObjects:phone1, phone2, phone3, phone4, phone5, nil];
    
    UITableView *tableView  = [self.view viewWithTag:1];
    [tableView registerClass:[CustomTableViewCell class] forCellReuseIdentifier:cellIdentifier];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark-
#pragma mark tableview of datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.phoneBook count];
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CustomTableViewCell *cell   = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
   
    NSDictionary *cellDictionary  = [self.phoneBook objectAtIndex:[indexPath row]];
    cell.name       = [cellDictionary objectForKey:@"Name"];
    cell.phone      = [cellDictionary objectForKey:@"Phone"];
    return cell;
}


@end
